package com.bleeth.fx.view.ssh;

import com.bleeth.fx.component.MButton;
import com.bleeth.fx.helper.SStyleHelper;
import com.bleeth.fx.helper.ThemeHelper;
import com.bleeth.fx.layout.BaseBuilder;
import com.bleeth.fx.layout.GirdBuilder;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
 * @author ：Bleeth
 * @date ：2022-03-15
 * @description：
 */
public class SSHView extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {

        GirdBuilder rightPaneGBer = GirdBuilder.create()
                .addVBuilder(
                        BaseBuilder.create().setId("row-title").setHeight(50D),
                        BaseBuilder.create().setId("empty").setHeight(20D),
                        BaseBuilder.create().setId("row-username").setHeight(30D).setSpacing(20D),
                        BaseBuilder.create().setHeight(40D),
                        BaseBuilder.create().setId("row-password").setHeight(30D).setSpacing(20D),
                        BaseBuilder.create().setHeight(40D),
                        BaseBuilder.create().setId("row-login").setHeight(40D).setSpacing(20D),
                        BaseBuilder.create().setId("1").setHeight(40D).setSpacing(20D),
                        BaseBuilder.create().setId("row-2").setHeight(40D).setSpacing(20D)
                )
                .addRow("row-title", BaseBuilder.create().setSpan(1).setPos(Pos.CENTER))
                .addCell(0, "title", new Label("欢迎大家的到来"))

                .addRow("row-username", BaseBuilder.create().setSpan(1), BaseBuilder.create().setWidth(80D).setPos(Pos.CENTER_RIGHT),
                        BaseBuilder.create().setWidth(300D).setPos(Pos.CENTER_LEFT), BaseBuilder.create().setSpan(1))
                .addCell(1, "label-username", new Label("用户名"))
                .coverCell(2, "input-username", new TextField(""))

                .addRow("row-password", BaseBuilder.create().setSpan(1), BaseBuilder.create().setWidth(80D).setPos(Pos.CENTER_RIGHT),
                        BaseBuilder.create().setWidth(300D).setPos(Pos.CENTER_LEFT), BaseBuilder.create().setSpan(1))
                .addCell(1, "label-password", new Label("密  码"))
                .coverCell(2, "input-password", new TextField(""))

                .addRow("row-login", BaseBuilder.create().setSpan(1).setPos(Pos.CENTER), BaseBuilder.create().setWidth(150D).setPos(Pos.CENTER), BaseBuilder.create().setSpan(1).setPos(Pos.CENTER))
                .coverCell(1, "btn-login", MButton.builder().type(ThemeHelper.PRIMARY).text("登  录").build().make());
        VBox mainBox = rightPaneGBer.build();

        SStyleHelper.node(rightPaneGBer.getRowPaneList().get(0))
                .addStyle("-fx-background-color", "#ff4347")
                .apply();
        SStyleHelper.copyStyle(rightPaneGBer.getRowPaneList().get(0),rightPaneGBer.getRowPaneList().get(3));

        Scene scene = new Scene(mainBox, 1200D, 800D);
        mainBox.prefHeightProperty().bind(scene.heightProperty());
        mainBox.prefWidthProperty().bind(scene.widthProperty());
        primaryStage.setResizable(false);
        primaryStage.setScene(scene);
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }

}
